<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title></title>
</head>

<body>
	<form action="saveGoods.php" method="post" onsubmit="return myPreDo()">
		商品编号:<input id="goodsId" type="text" name="goodsId" /><br />
		商品名称:<input id="goodsName" type="text" name="goodsName" /><br />
		商品类型:<select id="typeId" name="typeId"></select><br />
		商品价格:<input id="goodsPrice" type="text" name="goodsPrice" /><br />
		商品数量:<input id="goodsCount" type="number" name="goodsCount" /><br />
		商品描述:<input type="text" name="goodsDesc" /><br />
		商品图片:<input type="text" name="goodsImg" /><br />
		备用1:<input type="text" name="beiyong1" /><br />
		备用2:<input type="text" name="beiyong2" /><br />
		备用3:<input type="text" name="beiyong3" /><br />
		备用4:<input type="text" name="beiyong4" /><br />
		备用5:<input type="text" name="beiyong5" /><br />
		备用6:<input type="text" name="beiyong6" /><br />
		备用7:<input type="text" name="beiyong7" /><br />
		备用8:<input type="text" name="beiyong8" /><br />
		备用9:<input type="text" name="beiyong9" /><br />
		备用10:<input type="text" name="beiyong10" /><br />
		备用11:<input type="text" name="beiyong11" /><br />
		备用12:<input type="text" name="beiyong12" /><br />
		备用13:<input type="text" name="beiyong13" /><br />
		<input type="submit" value="保存商品" />
	</form>

</body>

</html>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="./js/tools.js"></script>
<script>

	function myPreDo() {
		let objs = {
			"goodsId": "商品编号", "goodsName": "商品名称", "typeId": "商品类型", "goodsPrice": "商品价格", "goodsCount": "商品数量"
		}
		return preDo(objs);
	}


	$(function () {
		$.get("getGoodsType.php", function (data) {
			let objs = JSON.parse(data);
			let htmlStr = "";
			objs.forEach(function (item) {
				htmlStr += `<option value="${item.typeId}" >${item.goodsType}</option>`;
			});
			$("#typeId").html(htmlStr);
		});

	});
</script>